<template>
  <el-form-item :label="label" :prop="prop">
    <el-input
      v-model="value"
      show-password
      :disabled="disable"
      auto-complete="new-password"
      :clearable="clearable"
      :placeholder="placeholder"
      spellcheck="false"></el-input>
  </el-form-item>
</template>

<script>
export default {
  name: "passwordInput",
  props: {
    // 显示标签
    label: {
      type: String,
      default() {
        return ''
      }
    },
    // 表单验证
    prop: {
      type: String,
      default() {
        return ''
      }
    },
    // 输入提示
    placeholder: {
      type: String,
      default() {
        return '请输入' + this.label.replace(/[:：]/,'')
      }
    },
    // 清空按钮
    clearable: {
      type: Boolean,
      default() {
        return true
      }
    },
    // 清空表单标志位
    clearFla: Boolean,
    // 是否可用
    disable: {
      type: Boolean,
      default() {
        return false
      }
    }
  },
  data() {
    return {
      // 输入的数据
      value: ''
    }
  },
  watch: {
    value() {
      this.$emit('valueChangeEvent',this.prop,this.value)
    },
    clearFla() {
      this.value = ''
    },
  },
  mounted() {
    // 设置value，使用事件形式
    this.$on('setValue', (prop,newValue) => {
      if (prop == this.prop) this.value = newValue
    })
  }
}
</script>

<style scoped>

</style>
